﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Joyintech.Model.inpiao365;
using Joyintech.BLL.inpiao365;

namespace Joyintech.Web.inpiao365.UserCenter
{
    public partial class MyHappy_PersonInfo : System.Web.UI.Page
    {
        protected String loginName;
        protected void Page_Load(object sender, EventArgs e)
        {
            customer customer = customer_BLL.GetInstance().GetCurrentCustomer();
            if (customer == null)
            {
                Response.Redirect("UserLogin.aspx");
            }
            if (!IsPostBack)
            {
                loginName = customer.CustomerName;
                Bind();

            }
        }

        protected void Bind()
        {
            customer customer = customer_BLL.GetInstance().GetCurrentCustomer();
            TxtNickName.Text = customer.CustomerName;
            TxtRealName.Text = customer.CustomerRealName;
            CustomerQQ.Text = customer.CustomerQQ;
            CustomerMsn.Text = customer.CustomerMsn;
            CustomerWeibo.Text = customer.CustomerWeibo;
            RbtGenter.SelectedValue = customer.CustomerSex;
            CustomerBirthday.Text = customer.CustomerBirthday;
            DDLContellation.SelectedValue = customer.CustomerConstellation;
            txtCity.Text = customer.CustomerResidence;
            TxtHomeTown.Text = customer.CustomerHometown;
            DDLBloodType.SelectedValue = customer.CustomerFigure;
            DDLBloodType.SelectedValue = customer.CustomerBlood;
            DDLMatrimony.Text = customer.CustomerMarriage;
            CustomerLikeTheater.Text = customer.CustomerLikeTheater;
            CustomerLikeMovie.Text = customer.CustomerLikeMovie;
            CustomerLikeMovieKeyWord.Text = customer.CustomerLikeMovieKeyWord;
            CustomerLikeMovieStar.Text = customer.CustomerLikeMovieStar;
            CustomerLikeMovieSite.Text = customer.CustomerLikeMovieSite;

        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            customer customer = customer_BLL.GetInstance().GetCurrentCustomer();
            customer.CustomerName = TxtNickName.Text;
            customer.CustomerRealName = TxtRealName.Text;
            customer.CustomerQQ = CustomerQQ.Text;
            customer.CustomerMsn = CustomerMsn.Text;
            customer.CustomerWeibo = CustomerWeibo.Text;
            customer.CustomerSex = RbtGenter.SelectedValue;
            customer.CustomerBirthday = CustomerBirthday.Text;
            customer.CustomerConstellation = DDLContellation.SelectedValue;
            customer.CustomerResidence = txtCity.Text;
            customer.CustomerHometown = TxtHomeTown.Text;
            customer.CustomerFigure = DDLBloodType.SelectedValue;
            customer.CustomerBlood = DDLBloodType.SelectedValue;
            customer.CustomerMarriage = DDLMatrimony.Text;
            customer.CustomerLikeTheater = CustomerLikeTheater.Text;
            customer.CustomerLikeMovie = CustomerLikeMovie.Text;
            customer.CustomerLikeMovieKeyWord = CustomerLikeMovieKeyWord.Text;
            customer.CustomerLikeMovieStar = CustomerLikeMovieStar.Text;
            customer.CustomerLikeMovieSite = CustomerLikeMovieSite.Text;
            int result = customer_BLL.GetInstance().UpdateAutoCheck(customer);
            if (result > 0)
            {
                //向Memcached中更新SessionId对应的当前登录会员实体
                customer_BLL.GetInstance().StoreCurrentCustomer(HttpContext.Current.Session.SessionID, customer);
            }
            else
            {

            }

        }
    }
}